<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" ><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" >
<head>
<title>ChelleWeb KLAS</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />

<link rel="stylesheet" href="css/screen.css" type="text/css" />
<?php
echo $_SESSION['id'];
/*session_start();
if($_SESSION['myusername'] != "secretword") {
echo $_SESSION['myusername'];
echo "no way dude";
}*/
$check = TRUE;
include('/PHP/database.php');
$db = new db();
if(isset($_POST["maak"])) { /* Maak klas is clicked */
	if($_POST["klas"] != ""){
		$msg = $db->set_klas($_POST["klas"]);
	} else {
		$db = new db();
		$msg = "Gelieve een Klas in te vullen";
	}
}
if(isset($_POST["delete"])) { /* delete klas is clicked */
	$del = $_POST["klaslijst"];
	$msg = $db->del_klas($del);
}
$contRAW = $db->get_klas();
$cont = "";
while ($row = mysql_fetch_assoc($contRAW)) {
    		$cont .= '<option value="' . $row["gid"] . '">' . $row["gname"] . '</option>';
		}
?>
</head>
<body>
<div id="main" >
<div id="banner" >
<h1>ChelleWeb 4 teh WINzor</h1>
</div>
<div id="border">
<div id="left">
			<ul>
			<li><a href="index.php?link=home">Home</a></li> 
			<li><a href="index.php?link=tips">Tips</a></li>
			<li><a href="index.php?link=Vragen">Vragen</a></li>
			<li><a href="index.php?link=contact">Contact</a></li>
			<li><a href="admin.php">Admin</a>
				<ul>
					<li><a href="admin.php">Teksten</a></li>
                    <li><a href="klas.php">Klassen</a></li>
					<li><a href="taak.php">Taken</a></li>
				</ul>
			</li>
            <li><a href="users.php">Gebruikers</a>
				<ul>
					<li><a href="/PHP/users.php">Lijsten</a></li>
					<li><a href="/PHP/logoff.php">Uitloggen</a></li>
				</ul>
			</li>
		</ul>
	</div>
<div id="content" >
<div id="right">
</div>
	<div id="text">
        <h2>Administration Page - use with care</h2>
		<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
			<table border="0">
				<tr>
					<td>Klassen:</td>
					<td><select name="klaslijst"><?php echo $cont; ?></select><input type="submit" name="delete" value="delete" /></td>
				</tr>
            </table>
			<p>
            	Maak Klas:<input type="text" name="klas" id="klas" /><input type="submit" name="maak" value="Maak" />
			</p>
			<input type="checkbox" name="error" value="error" /> Error reporting
		</form>
		<div id="msg">
		<?php echo $msg; ?>
		</div>
		</div>
</div>
<div id="footer">
	<ul>
		<li><a href="admin.php">admin</a> &#149 </li> 
		<li><a href="index.php?link=pr">pr</a> &#149 </li>
		<li><a href="index.php?link=marketing">marketing</a> &#149</li>
		<li><a href="index.php?link=eventman">event management</a></li>
	</ul>
</div>
</div>
</div>
<?php
if (isset($_POST["error"])){
		echo "ERROR is activated: <br />";
	$err = $db->error();
	echo $err;
}
?>
</body>
</html>